﻿package com.dnd.smashtehugly.helpers{

	import com.dnd.smashtehugly.helpers.model.ObjectBorder;
	import com.greensock.TweenMax;
	
	import flash.display.MovieClip;
	import flash.geom.Point;
	
	import org.flintparticles.common.actions.*;
	import org.flintparticles.common.counters.*;
	import org.flintparticles.common.displayObjects.*;
	import org.flintparticles.common.initializers.*;
	import org.flintparticles.twoD.actions.*;
	import org.flintparticles.twoD.emitters.Emitter2D;
	import org.flintparticles.twoD.initializers.*;
	import org.flintparticles.twoD.zones.*;

	
	public final class EffectFactory {
		
		//--------------------- COMMON EFFECTS ----------------------//
		
		public static function applyBorder(target:MovieClip, border:ObjectBorder):void{
			TweenMax.to(target, 0, {glowFilter:{alpha:1, color:border.Color, blurX:border.Thickness, blurY:border.Thickness, strength:border.Thickness*10}});
		}
		
		public static function removeBorder(target:MovieClip):void{
			TweenMax.to(target, 0, {glowFilter:{alpha:0}});
		}

		//--------------------- SPECIAL EFFECTS ----------------------//
		/**
		 * Star
		 **/
		public static function effect_Slam():Emitter2D{
			var emitter:Emitter2D = new Emitter2D();
			
			emitter.counter=new Blast(10);
			
			emitter.addInitializer(new Lifetime(0.1,0.5));
			emitter.addInitializer(new Velocity(new DiscZone(new Point(emitter.x, emitter.y), 100, 100)));
			emitter.addInitializer(new ImageClass(Star, 10) );
			
			emitter.addAction(new Age());
			emitter.addAction(new Move());
			emitter.addAction(new ScaleImage(0.5,1.5));
			emitter.addAction(new Fade(1.0,0.5));
			emitter.addAction(new ColorChange(0xFF0033FF, 0xFFFFFFFF));
			
			return emitter;
		}
		
		public static function effect_SlamRing():Emitter2D{
			var emitter:Emitter2D = new Emitter2D();
			
			emitter.counter=new Blast(3);
			
			emitter.addInitializer(new Lifetime(1,1.5));
			emitter.addInitializer(new Velocity(new DiscZone(new Point(emitter.x, emitter.y), 5, 2)));
			emitter.addInitializer(new SharedImage( new UglyShadow()));
			
			emitter.addAction(new Age());
			emitter.addAction(new Move());
			//emitter.addAction(new ScaleImage(0.5,1.5));
			//emitter.addAction(new Fade(1.0,0.5));
			//emitter.addAction(new ColorChange(0xFF0033FF, 0xFFFFFFFF));
			//emitter.addAction(new Rotate());
			
			return emitter;
		}
	}

}